package com.bx.implatform.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @author chilson
 * @date 2025-04-04 17:32:09
 */@Configuration
public class RestTemplateConfig {

    @Bean
    public RestTemplate restTemplate() {
        // 如果需要忽略 SSL 证书验证（仅测试环境使用）
        HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
        factory.setConnectTimeout(5000); // 连接超时时间（毫秒）

        // 忽略证书验证（谨慎使用）
        // factory.setHttpClient(createUnsafeHttpClient());

        return new RestTemplate(factory);
    }
 }